package com.binarysoft.service.obj.dao;

import java.util.Collection;

import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

public interface ObjectPropertyDAO extends ObjectPropertyMapper {
	@Select({ "select", "obj_id, prop_id, prop_name, prop_value, is_locked", "from object_property" })
	@Results({ @Result(column = "obj_id", property = "objId", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "prop_id", property = "propId", jdbcType = JdbcType.VARCHAR, id = true),
			@Result(column = "prop_name", property = "propName", jdbcType = JdbcType.VARCHAR), @Result(column = "prop_value", property = "propValue", jdbcType = JdbcType.VARCHAR),
			@Result(column = "is_locked", property = "isLocked", jdbcType = JdbcType.BIT) })
	Collection<ObjectProperty> selectAll();

	@Select({ "select", "obj_id, prop_id, prop_name, prop_value, is_locked", "from object_property", "where obj_id = #{objId,jdbcType=INTEGER}" })
	@Results({ @Result(column = "obj_id", property = "objId", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "prop_id", property = "propId", jdbcType = JdbcType.VARCHAR, id = true),
			@Result(column = "prop_name", property = "propName", jdbcType = JdbcType.VARCHAR), @Result(column = "prop_value", property = "propValue", jdbcType = JdbcType.VARCHAR),
			@Result(column = "is_locked", property = "isLocked", jdbcType = JdbcType.BIT) })
	Collection<ObjectProperty> selectByObjectId(long objId);

	@Select({ "select", "obj_id", "from object_property", "where prop_id = #{propId,jdbcType=VARCHAR}" })
	@Results({ @Result(column = "obj_id", property = "objId", jdbcType = JdbcType.INTEGER, id = true) })
	Collection<Long> selectObjectIds(String propId);

	@Select({ "select", "obj_id", "from object_property", "where prop_id = #{propId,jdbcType=VARCHAR}", "and prop_value = #{propValue,jdbcType=VARCHAR}" })
	@Results({ @Result(column = "obj_id", property = "objId", jdbcType = JdbcType.INTEGER, id = true) })
	Collection<Long> selectObjectIds(String propId, String propValue);
}